<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目迭代列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">

            <div th:if="${addFlag}" class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" >
                    <i class="fa fa-plus"></i> 添加
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('project:projectPlan:edit')}]];
        var removeFlag = [[${@permission.hasPermi('project:projectPlan:remove')}]];
        var statusDatas = [[${@dict.getType('sys_project_status')}]];

        var addFlag = [[${addFlag}]] == false ? "hidden" : "";

        var prefix = ctx + "project/projectPlan";
        var parems = "";
        parems = parems+"projectId=" + [[${projectId}]];
        $(function() {
            var options = {
                url: prefix + "/list?"+parems,
                createUrl: prefix + "/add?"+parems,
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "项目迭代",
                columns: [
                {
                    field: 'id', 
                    title: '迭代id',
                    visible: false
                },
                {
                    field: 'projectId', 
                    title: '项目id',
                    visible: false
                }, {
                        field: 'projectName',
                        title: '项目名称'
                    },
                {
                    field: 'name', 
                    title: '迭代名称'
                },
                {
                    field: 'contentDescribe',
                    title: '描述'
                },
                    {
                        field: 'empId',
                        title: '负责人Id',
                        visible: false
                    },{
                        field: 'empName',
                        title: '负责人'
                    },
                {
                    field: 'startTime', 
                    title: '开始时间'
                },
                {
                    field: 'endTime', 
                    title: '结束时间'
                },
                {
                    field: 'status', 
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'createId', 
                    title: '创建者id',
                    visible: false
                },
                {
                    field: 'updateId', 
                    title: '更新者id',
                    visible: false
                },
                {
                    field: 'remark', 
                    title: '备注',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="openHtml(\''+'项目迭代成员'+'\',\''+'/project/projectEmp/projectEmpInfo?type=1&projectId=' + row.projectId +"&projectPlanId=" + row.id +'\')"><i class="fa fa-edit"></i>成员</a> ');
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="openHtml(\''+'任务列表'+'\',\''+'/project/projectPlanTask/projectPlanTaskInfo?type=2&projectId=' + row.projectId +"&projectPlanId=" + row.id +'\')"><i class="fa fa-edit"></i>任务列表</a> ');
                        if (row.status == 0){
                            actions.push('<a class="btn btn-danger btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>关闭</a>');
                            actions.push('<a class="btn btn-success btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            if ((row.empId+"") == '[[${userId}]]'){
                                actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="finishPlan(\''+ row.id +'\')"><i class="fa fa-edit"></i>完成</a> ');
                            }
                        }

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function openHtml(title,url) {
            $.modal.openMain(title , url,($(window).width() - 20),($(window).height() - 20),null,1);
        }

        function finishPlan(id) {
            $.modal.confirm("确定完成了吗?", function() {
                $.operate.submit(prefix + "/finishPlan?id="+id);
            });

        }

    </script>
</body>
</html>